package com.softserveinc.edu.oms;

import java.util.List;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import com.softserveinc.edu.oms.persistence.dao.concrete.ProductDao;
import com.softserveinc.edu.oms.persistence.dao.concrete.UserDao;
import com.softserveinc.edu.oms.persistence.dao.params.SelectCondition;
import com.softserveinc.edu.oms.persistence.dao.params.UserSelectField;
import com.softserveinc.edu.oms.persistence.entities.Product;
import com.softserveinc.edu.oms.persistence.entities.User;

public class Main {
	public static void main(final String[] args) {
		SessionFactory sessionFactory = new Configuration().configure()
				.buildSessionFactory();

		UserDao userDao = new UserDao(sessionFactory);

		List<User> users = userDao.findUsersBySearchValue("supervisor",
				UserSelectField.ALL, SelectCondition.EQUALS);

		for (User user : users) {
			System.out.println(user);
		}

		ProductDao productDao = new ProductDao(sessionFactory);
		System.out.println("containsProductByDescription - "
				+ productDao.containsProductByDescription(""));
		System.out.println("containsProductByName - "
				+ productDao.containsProductByName(""));
		System.out.println("numberOfProductByName - "
				+ productDao.numberOfProductByName(""));
		System.out.println("numberOfProductByDescription - "
				+ productDao.numberOfProductByDescription(""));
		List<Product> listProduct = productDao.findByName("");
		for (Product pr : listProduct) {
			System.err.println(pr);
		}

		for (Product pr : productDao.findByDescription("")) {
			System.out.println(pr);
		}
		for (Product pr : productDao.findByPrice(100.0)) {
			System.out.println(pr);
		}
		for (Product pr : productDao.findByPriceFromTo(100.0, 200.0)) {
			System.out.println(pr);
		}

	}
}
